<?php
require_once(SITE_ROOT."/includes/application/SignApplication.php");
require_once(SITE_ROOT."/includes/checksession.php");
//require_once(SITE_ROOT."/includes/tools/fk_check.php");
//require_once(SITE_ROOT."/includes/tools/fk_utils.php");
//require_once(SITE_ROOT.'/includes/tools/fk_string.php');
//require_once(SITE_ROOT.'/includes/tools/fk_datetime.php');
require_once("Ajax.php");
class SignAjax extends Ajax {
    public $app;
    function __construct(){
        $this->app = Wzx::getElementObject(0);
    }
    
    private function signup(){
    	global $gSmarty;
    	$username = $_POST['username'];
    	$password = $_POST['password'];
    	$nickname = $_POST['nickname'];
    	$sex = $_POST['sex'];
    	$result = $this->app->signUp($username.$password,$nickname,$sex);
    	if($result == 0){
    		$gSmarty->assign("username",$username);
    		$this->template = "member/sign/signup_down.dwt";
    		$this->fetch();
    	}else{
    		echo "{rtn_code:'1'}";
    	}
    }
    private function maidou_1(){
    	$birth = $_POST['birth'];
    	$edu = $_POST['edu'];
    	$career = $_POST['career'];
    	$single = $_POST['single'];
    	$smoke = $_POST['smoke'];
    	$drink = $_POST['drink'];
    	$pet = $_POST['pet'];
    	$blood = $_POST['blood'];
    	$intro = $_POST['intro'];
    	$userId = $_SESSION['G_USERID'];
    	$rtn = $this->app->maidou_1($userId,$birth,$edu,$career,$single,$smoke,$drink,$pet,$blood,$intro);
    	if($rtn == 0){
    		echo "{rtn_code:'0'}";
    	}else{
    		echo "{rtn_code:'$rtn'}";
    	}
    }
	private function getUpFace(){
		$uploadDir = $_GET['uploadDir'];
		$userId = $_SESSION['G_USERID'];
		$rtn = $this->app->setuploadUserFace($userId,$uploadDir);
		echo "<img src='/static/user/".$userId."/face/".$rtn."' />";
		
	}
    public function prepare(){
        $act = $_GET['act'].$_POST['act'];
        if($act=='signup') {
            $this->signup();
        }elseif ($act=='maidou_1'){
        	$this->maidou_1();
        }elseif($act=="getUpFace"){
        	$this->getUpFace();
        }
    }
}